<?php
abstract class Custom_Enum {
	private $_constants;
	// array
	private $_index;
	// string

	public function __construct() {
		$rc = new ReflectionClass($this);
		$this -> _constants = $rc -> getConstants();
	}

	public function __call($method, $args) {
		if (preg_match('/^is([a-zA-Z]*?)$/', $method, $matches)) {
			return $this -> is($matches[1]);
		}
		$this -> set($method);
		return $this;
	}

	public function __toString() {
		return (string)$this -> getValue();
	}

	public function set($index) {
		$this -> _index = strtoupper($index);
		return $this;
	}

	public function is($index) {
		return strtoupper($index) == $this -> _index;
	}

	public function getValue() {
		return $this -> _constants[$this -> _index];
	}

}
?>